{**
 * Haefko - your php5 framework
 *
 * @author      Jan Skrasek
 * @copyright   Copyright (c) 2007 - 2009, Jan Skrasek
 * @link        http://haefko.skrasek.com
 * @license     http://www.opensource.org/licenses/mit-license.html
 * @version     0.9 - $Id: data-grid.template.phtml 212 2009-08-21 11:56:55Z skrasek.jan $
 * @package     Haefko
 *}
{noEscape $grid}
<table class="datagrid">
<thead>
	<tr>
	{foreach $grid->columns as $column}
		<th>
			{if in_array($column, $grid->orderable) || empty($grid->orderable)}
				{$html->link($grid->paramUrl('order', $grid->getOrderState($column)),
				 				$grid->columnLabel($column) . $grid->columnStateNum($column),
				                $grid->columnStateClass($column), false)}
			{else}
				{$grid->columnLabel($column)}
			{/if}
		</th>
	{/foreach}
	{if $grid->showActions}
		<th>Actions</th>
	{/if}
	</tr>
</thead>
<tbody>
	{foreach $rows as $i => $row}
	<tr{php echo ($i % 2) ? ' class="odd"' : ''}>
	{foreach $row as $name => $field}
		{if (!empty($grid->columns) && !in_array($name, $grid->columns))}
			{continue}
		{/if}
		<td>{$field}</td>
	{/foreach}
	{if $grid->showActions}
		<td>{$grid->invokeActionsCallback($this, $row)}</td>
	{/if}
	</tr>
	{/foreach}
</tbody>
<tfoot>
	<tr>
	<td colspan="{=count($grid->columns) + ($grid->showActions ? 1 : 0)}">
		<div class="datagrid-pagination">
			{php $paginator = $grid->query->paginator}

			{if !$paginator->isFirst()}
				<a href="{$grid->paramUrl('page', 1)}"><span class="first">First</span></a>
				<a href="{$grid->paramUrl('page', $paginator->page - 1)}"><span class="prev">Previous</span></a>
			{else}
				<span class="first-off">First</span>
				<span class="prev-off">Previous</span>
			{/if}

			<form style="display: inline">
			{if $grid->getVar('order') != null}
				<input type="hidden" name="{$grid->name}-order" value="{$grid->getVar('order')}" />
			{/if}

			{php $page = $grid->getVar('page')}
			{php $page = empty($page) ? 1 : $page}
			Page <input type="text" name="{$grid->name}-page" value="{$page}" class="text" /> of {$paginator->pages}
			</form>

			{if !$paginator->isLast()}
				<a href="{$grid->paramUrl('page', $paginator->page + 1)}"><span class="next">Next</span></a>
				<a href="{$grid->paramUrl('page', $paginator->pages)}"><span class="last">Last</span></a>
			{else}
				<span class="next-off">Next</span>
				<span class="last-off">Last</span>
			{/if}
		</div>
	</td>
	</tr>
</tfoot>
</table>